package test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.concurrent.TimeUnit;

import static java.lang.Thread.sleep;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.WebDriverWait;


public class _27 {




        public static void main(String[] args) throws InterruptedException {
            //text02();
            // text03();
            //text04();
            //text05();
//text06();
            text07();
        }

        private static void text07() throws InterruptedException {
            //打开百度首页
            ChromeOptions options=new ChromeOptions();
            options.addArguments("-remove--allow-origins");
            WebDriver webDriver=new ChromeDriver();
            webDriver.get("http://baidu.com");
            //搜索521
            webDriver.findElement(By.cssSelector("#kw")).sendKeys("521");
            webDriver.findElement(By.cssSelector("#su")).click();
            sleep(3000);
            //强制等待3秒
            WebDriverWait wait =new WebDriverWait(webDriver,3);
            //浏览器后退
            webDriver.navigate().back();
            sleep(3000);
            webDriver.navigate().refresh();//刷新
            sleep(3000);
            webDriver.navigate().forward();//前进
            sleep(3000);
            ((JavascriptExecutor)webDriver).executeAsyncScript("document.documentElement.scrollTop=1999");//滚动条下滑，如果自动化测试与预期结果不一致多半是因为渲染出现问题
            webDriver.manage().window().maximize();
            sleep(3000);
            webDriver.manage().window().fullscreen();
            sleep(3000);
            webDriver.manage().window().setSize(new Dimension(600,1000));


        }

    }
